package com.jzo2o.foundations.controller.operation;


import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-08-16
 */
@RestController
@RequestMapping("/operation/serve")
@Api(tags = "运营端-区域服务相关接口")
public class ServeController {
    @Resource
    private IServeService serveService;
    //分页
    @GetMapping("/page")
    @ApiOperation("服务分页查询")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO dto) {
        return serveService.page1(dto);
    }

    //添加
    @PostMapping("/batch")
    @ApiOperation("新增区域服务")
    public void addBatch(@RequestBody List<ServeUpsertReqDTO> dto) {
        serveService.addBatch(dto);

    }
    //上架
    @PutMapping("/onSale/{id}")
    @ApiOperation("区域服务上架")
    public void onSale(@PathVariable("id") Long id) {
        serveService.onSale(id);
    }

}
